<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加内容</title>
</head>
<body>

<script type="text/html" id="form">
    <div class="mainBox">
        <div class="main-container">
            <input type="hidden" name="relation_id" value="{{facade.getUrlParam('game_id')}}">
            <blockquote class="layui-elem-quote">基础信息</blockquote>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    内容标题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入内容标题"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <text style="color:red;">支持jpg、png，大小不超过5M，图片尺寸建议 5:3比例</text>
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    内容图标</label>
                <div class="layui-input-block">
                    <div class="laytpUpload"
                         data-name="icon"
                         data-dir="xm_game/calendar/content/icon"
                         data-accept="image"
                         data-type="ali-oss"
                         data-layVerify="required"
                         data-showChoiceBtn="false"
                    ></div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    获取方式</label>
                <div class="layui-input-block">
                    <input type="text" name="url"  autocomplete="off" placeholder="请输入获取方式"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    跳转地址</label>
                <div class="layui-input-block">
                    <input type="text" name="jump_url"  autocomplete="off"
                           placeholder="请输入跳转地址"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    序号</label>
                <div class="layui-input-block">
                    <input type="number" name="sort" lay-verify="required" autocomplete="off" placeholder="请输入序号"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <text title="必填项" style="color:red;">*</text>
                    活动时效</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input laydate"
                           id="create_time" name="time"
                           data-type="datetime" data-isRange="true" placeholder="请选择活动时效时间">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-item">
                    <label class="layui-form-label" title="启用状态">
                        <text title="必填项" style="color:red;">*</text>
                        状态</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="status"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'正常',value:'1'},{name:'下架',value:'2'}]"
                             data-selected="1"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" title="订阅状态">
                        能否订阅状态</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="subscribe_status"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'是',value:'1'},{name:'否',value:'2'}]"
                             data-selected=""
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" title="标签状态">
                        标签展示状态</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="label_status"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'是',value:'1'},{name:'否',value:'2'}]"
                             data-selected=""
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" title="类别">
                        <text title="必填项" style="color:red;">*</text>
                        类别</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="category_id"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'活动类别',value:'1'},{name:'资讯类别',value:'2'}]"
                             data-selected=""
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" title="内容类型">
                        <text title="必填项" style="color:red;">*</text>
                        内容类型</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="type"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'视频类型',value:'1'},{name:'文章类型',value:'2'}]"
                             data-selected=""
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" title="归属模块">
                        <text title="必填项" style="color:red;">*</text>
                        归属模块</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="module_id"
                             data-sourceType="route"
                             data-source="/admin.calendar.module/index"
                             data-params='{"search_param":{"relation_id":{"value":"{{facade.getUrlParam("game_id")}}","condition":"="},"status":{"value":"1","condition":"="}}}'
                             data-sourceTree="false"
                             data-paging="true"
                             data-valueField="id"
                             data-textField="name"
                             data-radio="true"
                             data-placeholder="请选择模块"
                             data-selected=""
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" title="标签">
                        <text title="必填项" style="color:red;">*</text>
                        标签</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="label_id"
                             data-sourceType="route"
                             data-source="/admin.calendar.label/index"
                             data-params='{"search_param":{"relation_id":{"value":"{{facade.getUrlParam("game_id")}}","condition":"="},"status":{"value":"1","condition":"="}}}'
                             data-sourceTree="false"
                             data-paging="true"
                             data-valueField="id"
                             data-textField="name"
                             data-radio="true"
                             data-placeholder="请选择标签"
                             data-selected=""
                        ></div>
                    </div>
                </div>


            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if (localStorage.getItem("staticDomain")) {
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    } else {
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    }
</script>
<script>
    layui.use(['laytp'], function () {
        let form = layui.form;
        layui.laytpl($("#form").html()).render([], function (string) {
            $("form").html(string);
            layui.laytpForm.render();
            form.render();
        });
        let game_id = facade.getUrlParam("game_id");
        layui.form.on('submit(add)', function (data) {
            var btnAnim = layui.button.load({elem: $(this)});
            facade.ajax({
                route: '/admin.calendar.content/add?game_id=' + game_id,
                data: data.field
            }).done(function (res) {
                if (res.code === 0) {
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function () {
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>